#include <vector>
#include <deque>
#include "node.h"

// Modification of Cromwell D. Enage's open heap.

	class OpenHeap
	{
		std::deque<node*> open;
		bool (*compare)(node const*, node const*);

	public:
		//! \brief Constructs a new <code>%OpenHeap</code> that heap-sorts nodes
		//! using the specified comparator.
		explicit OpenHeap(bool (*)(node const*, node const*));

		//! \brief Returns <code>true</code> if the heap contains no nodes,
		//! <code>false</code> otherwise.
		bool empty() const;

		//! \brief Removes all nodes from the heap.
		//!
		//! \post
		//!   - <code>empty()</code>
		void clear();

		//! \brief Returns the number of nodes currently in the heap.
		std::size_t size() const;

		//! \brief Pushes the specified node onto the heap.
		//!
		//! The heap will maintain the ordering of its nodes during this operation.
		//!
		//! \post
		//!   - <code>! empty()</code>
		void push(node* node);

		//! \brief Returns the least costly node in the heap.
		//!
		//! \pre
		//!   - <code>! empty()</code>
		node* front() const;

		//! \brief Removes the least costly node from the heap.
		//!
		//! The heap will maintain the ordering of its nodes during this operation.
		//!
		//! \pre
		//!   - <code>! empty()</code>
		void pop();

		//! \brief Removes all instances of the specified node from the heap.
		void remove(node const* node);

		//! \brief Enumerates all nodes in the heap so far.
		//!
		//! \param   sorted  the container to which each node will be added.
		//!
		//! \pre
		//!   - There must be no <code>NULL</code> pointers in the heap.
		//! \post
		//!   - All nodes should be sorted by this heap's comparator.
		void enumerate(std::vector<node const*>& sorted) const;
	};


